/*************************************************************************
	> File Name: hzoj_251.cpp
	> Author: 
	> Mail: 
	> Created Time: Sat 10 Aug 2024 07:19:31 PM CST
 ************************************************************************/

#include<iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n, X, Y, cost_x = 0, cost_y = 0;
	cin >> n;
	vector<int> x(n), y(n);
	for(int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	sort(x.begin(), x.end());
	for(int i = 0; i < n; i++) {
		x[i] = x[i] - i;
	}
	sort(x.begin(), x.end());
	X = x[n / 2];
	sort(y.begin(), y.end());
	Y = y[n / 2];
	for(int i = 0; i < n; i++) {
		cost_x += abs(x[i] - X);
		cost_y += abs(y[i]- Y);
	}
	cout << cost_x + cost_y << endl;
	return 0;
}
